#include <stdio.h>

int main(int argc, char *argv[]) 
{
	int i,year,month,d,day,sum,run,ping,n;
	scanf("%d",&i);
	
	for(int j=1;j<=i;j++)
		{
			scanf("%d%d%d",&year,&month,&day);
			run=(year-1988-1)/4;
			ping=year-1990-run;
			
			switch(month)
			{
				case 1:d=0;break;
				case 2:d=31;break;
				case 3:d=59;break;
				case 4:d=90;break;
				case 5:d=120;break;
				case 6:d=151;break;
				case 7:d=181;break;
				case 8:d=212;break;
				case 9:d=243;break;
				case 10:d=273;break;
				case 11:d=304;break;
				case 12:d=334;break;
			}
			if(year%4==0&&month>2)d=d+1;
			sum=run*366+ping*365+d+day;
			n=sum%5;
			switch(n)
			{
				case 1:case 2:case 3:printf("He was fishing on %d.%d.%d\n",year,month,day);break;
				case 4:case 0:printf("He was basking on %d.%d.%d\n",year,month,day);break;
			}
		}
}